package com.acme.bankapp.domain.accounting;

abstract class AbstractAccount implements Account {
	
	public static final double DEFAULT_INITIAL_BALANCE = 0;


	protected double balance;

	/**
	 * common constructor
	 * @param balance Initial balance
	 */
	public AbstractAccount(double balance) {
		if(balance < 0) throw new IllegalArgumentException("balance cannot be less then 0");
		this.balance = balance;
	}

	/**
	 * {@inheritDoc}
	 */
	public double getBalance() {
		return balance;
	}

	/**
	 * {@inheritDoc}
	 */
	public void deposit(double x) {
		balance += x;

	}

	/**
	 * {@inheritDoc}
	 */
    //[EK] XXX Do _any_ of subclasses follow this contract? Proof with tests.
	//[MA] implementation moved to subclasses
	public abstract void withdraw(double x) throws NotEnoughFundsException;

	
	/**
	 * {@inheritDoc}
	 */
	public abstract double maximumAmountToWithdraw();
}
